<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>

<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="renderer" content="webkit">
		 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="layui/css/layui.css"  media="all">
		
	</head>
	<body>
		
			
		<form class="layui-form" action="">
		  <div class="layui-form-item">
		    <label class="layui-form-label">座位号：</label>
		    <div class="layui-input-block">
		      <input type="text" name="eseatno" id="eseatno" disabled="disabled" placeholder=${param.eseatno } value=${param.eseatno } autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">自习室：</label>
		    <div class="layui-input-block">
		      <input type="text" name="rno" id="rno" disabled="disabled"  autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">开始时间：</label>
		    <div class="layui-input-block">
		      <input type="text" name="restime" id="restime" disabled="disabled"  autocomplete="off" class="layui-input">
		    </div>
		  </div>
		    
		    <div class="layui-inline">
		      <label class="layui-form-label">结束时间：</label>
		      <div class="layui-input-inline">
		        <input type="text" class="layui-input" id="resetime" placeholder="HH:mm:ss">
		      </div>
		    </div>
		  
		  
		  
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo" id="submit">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		  </div>
		</form>
		 
		 <script src="${pageContext.request.contextPath}/js/jquery-2.0.3.js"></script>

		<!--分页操作 2- 引入layui.js文件 -->
		<script src="layui/layui.js" charset="utf-8"></script>
		
		<script>
		//Demo
		var t = new Date();
			var h = t.getHours();
			var m = t.getMinutes();
			var s = t.getSeconds();
		layui.use('form', function(){
		  var form = layui.form;
		  
		  //监听提交
		  form.on('submit(formDemo)', function(data){
		    layer.msg(JSON.stringify(data.field));
		    return false;
		  });
		});
		
		//开始时间与结束时间的选择器
		layui.use('laydate', function(){
			  var laydate = layui.laydate;
				//时间选择器
				  //限定可选时间
				 
				laydate.render({
				    elem: '#resetime'
				    ,type: 'time'
			    	,min: '08:30:00'
				    ,max: '17:30:00'
				    ,btns: ['clear', 'confirm']
				  });
		});
			
		</script>
		
		<script type="text/javascript">
			var eseatno = $("#eseatno").val();
			var t = new Date();
			var h = t.getHours();
			var m = t.getMinutes();
			var s = t.getSeconds();
			console.log(h+":"+m+":"+s)
			//设置弹窗初始值
			$(function(){
		         $.ajax({
		        	 url:"SeatServlet",
		             type: "post",
		             data: {
		            	 eseatno:eseatno,
		            	 op:"reserGetOne"
		             },
		             dataType: "json",
		             success: function(res){
		            	 console.log("res"+res);
		            	 console.log(res);
		            	 $('#rno').val(res.Rno);
		            	 $('#restime').val(h+":"+m+":"+s);
	                  }
		         });
			});
			//提交事件
			$(function() {
				$("#submit").click(function() {
					$.ajax({
						url:"SeatServlet",
						type:"post",
						data:{
							eseatno:$("#eseatno").val(),
							rno:$("#rno").val(),
							restime:$("#restime").val(),
							resetime:$("#resetime").val(),
							op:"subRes"
						},
						daytType:"json",
						success: function(res){
							if(res=="true"){
								layer.alert('预定成功', {
									  icon: 1,
									 // skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
									  yes: function(layero, index){
											//当你在iframe页面关闭自身时
											var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
											parent.layer.close(index); //再执行关闭   
										  }
									});
								
							}else{
								layer.alert('预定失败', {
									  icon: 2,
									 // skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
									  yes: function(layero, index){
											//当你在iframe页面关闭自身时
											var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
											parent.layer.close(index); //再执行关闭   
										  }
									});
								
							};
							
						}
					});
					
				});
				
			});
		</script>
		
	</body>
</html>
</html>